package lims.cloud.oss.fileInfo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lims.cloud.system.base.exception.FileNotExistException;
import lims.cloud.system.base.mybatis.IBaseServiceImpl;
import lims.cloud.system.base.mybatis.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class FileInfoServiceImpl extends IBaseServiceImpl<FileInFoMapper, FileInfo> implements FileInfoService {

    private final FileInFoMapper fileInFoMapper;

    @Override
    public Result<FileInfo> getFileInfoByKeyword(String keyword) {
        LambdaQueryWrapper<FileInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FileInfo::getKeyWord, keyword);
        FileInfo fileInfo = fileInFoMapper.selectOne(queryWrapper);
        if (fileInfo == null) {
            throw new FileNotExistException();
        }
        return Result.ok(fileInfo);
    }
}
